package top.plgxs.basic.one;

/**
 * <p> 基本数据类型 </p>
 *
 * @author Stranger.
 * @since 2022/9/1 10:07
 */
public class DataType {
    public static byte byte1 = 127;
    public static short short1 = 128;
    public static int int1 = 128;
    public static long long1 = 128L;
    public static float float1 = 128F;
    public static double double1 = 128;
    public static char char1 = 'A';
    public static boolean boolean1 = false;

    public static void main(String[] args) {
        // boolean与其他7种类型无法转换
//        boolean1 = int1;
        // long类型的取值范围<float类型的取值范围,long转float无需强制转换
        float1 = long1;
        // char类型与byte、short的转换需要强制转换，char转int long float double不需要强制转换。
        byte1 = (byte) char1;
        short1 = (short) char1;
        int1 = char1;
        long1 = char1;
        float1 = char1;
        double1 = char1;

        char1 = (char) byte1;
        char1 = (char) short1;
        char1 = (char) int1;
        char1 = (char) float1;

        byte b1 = 127;
        byte b2 = b1++;
        byte b3 = ++b1;

        b1 = 127;
        byte b4 = (byte) (b1 + 1);
        byte b5 = (byte) (b1 + 2);
        System.out.println("b2=" + b2 + " , b3=" + b3);
        System.out.println("b4=" + b4 + " , b5=" + b5);


    }
}
